package com.zk.junit4;

import org.junit.runner.Description;
import org.junit.runner.Result;
import org.junit.runner.notification.RunListener;

/**
 * 测试Listener的说明
 */
public class Junit4DemoRunListener extends RunListener {

    /**
     * Called before any tests have been run. This may be called on an
     * arbitrary thread.
     *
     * @param description describes the tests to be run
     */
    @Override
    public void testRunStarted(Description description) throws Exception {
        System.out.println("testRunStarted:");
        System.out.println("  --Description:" + description);

    }

    /**
     * Called when all tests have finished. This may be called on an
     * arbitrary thread.
     *
     * @param result the summary of the test run, including all the tests that failed
     */
    public void testRunFinished(Result result) throws Exception {
        System.out.println("testRunFinished:");
        System.out.println("  --Result:" + result.getFailureCount());
        System.out.println("    Failures:" + result.getFailures());
    }

    /**
     * Called when a test suite is about to be started. If this method is
     * called for a given {@link Description}, then {@link #testSuiteFinished(Description)}
     * will also be called for the same {@code Description}.
     *
     * <p>Note that not all runners will call this method, so runners should
     * be prepared to handle {@link #testStarted(Description)} calls for tests
     * where there was no corresponding {@code testSuiteStarted()} call for
     * the parent {@code Description}.
     *
     * @param description the description of the test suite that is about to be run
     *                    (generally a class name)
     * @since 4.13
     */
    public void testSuiteStarted(Description description) throws Exception {
        System.out.println("testSuiteStarted:");
        System.out.println("  --Description:" + description);
    }


}
